﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<section class="content-header">
    <h1>
        无效用户管理
        <small></small>
    </h1>
    <ol class="breadcrumb"></ol>
</section>
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="box box-primary">
                <div class="box-header">
                    <div class="form-inline">
                        <div class="form-group">
                            <label>用户名</label>
                            <input type="text" class="form-control" style="width:100px;" maxlength="20" id="loginName" autocomplete="off" />
                        </div>
                        <div class="form-group">
                            <label>真实姓名</label>
                            <input type="text" class="form-control" style="width:100px;" maxlength="20" id="realName" autocomplete="off" />
                        </div>
                        <div class="form-group">
                            <button type="button" class="btn btn-success btn-sm" id="btnSearch">查询</button>
                        </div>


                        <h3 class="box-title"></h3>
                    </div>
                </div>
                <div id="datatable">

                </div>
                <!-- /.box-header -->
                <div class="box-footer clearfix ">
                    <ul id="pagination" class="pagination pagination-sm no-margin pull-right"></ul>
                </div>
            </div>
        </div>
    </div>
</section>
@section scriptsBottom{
    <script type="text/javascript">
        $(document).ready(function () {
            $("#btnSearch").click(function () {
                pageIndex = 1;
                search();
            });
            search();
        });

        //页码
        var pageIndex = 1;
        //查询
        function search() {
            var data = {
                loginName: $("#loginName").val(),
                realName: $("#realName").val(),
                rows: 10,
                page: pageIndex
            }
             $("#datatable").load('@Url.Action("ParInvalidUserList", "User")', data, function (data) {
                 document.getElementById('datatable').innerHTML = data;
                //alert($("#dataView").data("count"));
                //分页显示
                $('#pagination').twbsPagination("destroy");
                $('#pagination').twbsPagination({
                    totalItems: $("#dataView").data("count"),
                    visiblePages: 10,
                    pageSize: 10,
                    startPage: parseInt(pageIndex),
                    onPageClick: function (event, page) {
                        pageIndex = page;
                        search();
                    }
                });
            })
        }


        //激活用户
        function active(id) {
            var url = '@Url.Action("ActivateUser", "User")';
            BMCW.DataConfirm("激活用户会清除错误次数、移出黑名单、超期自动续期1年，确认激活该用户吗", function () {
                BMCW.ajax({
                    url: url,
                    type: "Post",
                    data: {
                        "id": id
                    },
                    success: function (o) {
                        console.log(o);
                        if (o.status == 0) {
                            BMCW.msg("激活成功", function () {
                                search();
                            });

                        } else {
                            BMCW.alert(o.message);
                        }
                    },
                    error: function (o) {
                        console.log(o);
                    }
                });
            })
        }
    </script>
}